import {
  getHoursBefore,
  getDayBefore,
  getMonthBefore,
  generateRandomValue
} from "./handler";

/**
 * 各楼栋收缴情况数据生成方法
 * @param {Object} key 传入筛选 key
 * @returns [Array<Object>] 返回工单数据
 */
export const generateCollectionData = key => {
  const data = [];
  const housesList = ["A栋", "B栋", "C栋", "D栋"];
  if (key == 0) {
    housesList.forEach(house => {
      data.push({
        name: house,
        paid: generateRandomValue(3),
        unpaid: generateRandomValue(3)
      });
    });
  }

  if (key == 1) {
    housesList.forEach(house => {
      data.push({
        name: house,
        paid: generateRandomValue(3),
        unpaid: generateRandomValue(3)
      });
    });
  }

  return data;
};

/**
 * 工单处理统计数据生成方法
 * @returns [Array<Object>] 返回工单数据
 */
export const generateEquipmentData = () => {
  return [
    {
      name: "供电状态",
      state: 1
    },
    {
      name: "火警状态",
      state: 1
    },
    {
      name: "供水状态",
      state: 1
    },
    {
      name: "环境状态",
      state: 1
    }
  ];
};

/**
 * 工单处理统计数据生成方法
 * @param {Object} key 传入筛选 key
 * @returns [Array<Object>] 返回工单数据
 */
export const generateWorkOrderData = key => {
  const data = [];
  if (key == 0) {
    const timeList = getHoursBefore();
    timeList.forEach(time => {
      data.push({
        name: time,
        fix: generateRandomValue(1),
        complain: generateRandomValue(1),
        order: generateRandomValue(1)
      });
    });
  }

  if (key == 1) {
    const dayList = getDayBefore();
    dayList.forEach(day => {
      data.push({
        name: day,
        fix: generateRandomValue(2),
        complain: generateRandomValue(2),
        order: generateRandomValue(2)
      });
    });
  }

  if (key == 2) {
    const monthList = getMonthBefore();
    monthList.forEach(month => {
      data.push({
        name: month,
        fix: generateRandomValue(3),
        complain: generateRandomValue(3),
        order: generateRandomValue(3)
      });
    });
  }

  return data;
};

/**
 * 代办提醒数据生成方法
 * @returns [Array<Object>] 返回工单数据
 */
export const generateTodoReminderData = () => {
  return [
    {
      id: 1,
      name: "A2-2楼梯口消防设备维修",
      date: "2023-11-25 18:26:36"
    },
    {
      id: 2,
      name: "#2号下水道堵塞",
      date: "2023-11-25 18:26:36"
    },
    {
      id: 3,
      name: "A2-2楼梯口消防设备维修",
      date: "2023-11-25 18:26:36"
    },
    {
      id: 4,
      name: "B1楼顶漏水,B1楼顶漏水,B1楼顶漏水,B1楼顶漏水",
      date: "2023-11-03 18:26:36"
    },
    {
      id: 5,
      name: "#3号下水道异常",
      date: "2023-10-11 18:26:36"
    },
    {
      id: 6,
      name: "A11-8楼梯口杂物堆积，未清理",
      date: "2023-09-25 18:26:36"
    },
    {
      id: 7,
      name: "C2大堂门口地面损坏",
      date: "2023-07-12 18:26:36"
    },
    {
      id: 8,
      name: "D10电梯异常，需要检修",
      date: "2023-05-12 18:26:36"
    }
  ];
};
